﻿@{
    ViewBag.Title = "CompanyAccount";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<script>
    $(function () {
        gridList();
        @*$("#gridList")
      .append(
          "@ViewBag.InSum");
  $("input", "#t_toolbar1").click(function() {
  });*@
    })
    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            url: "/SystemManage/User/GetCompanyAccount",
            height: $(window).height() - 128,
            colModel: [
                { label: '主键', name: 'ID', hidden: true },
                { label: '会员ID', name: 'Account', width: 80, align: 'left' },
                { label: '会员姓名', name: 'AccountName', width: 80, align: 'left' },
                { label: '账变类型', name: 'ChangeType', width: 160, align: 'left' },
                {
                    label: '进账出账', name: 'IsIncome', width: 70, align: 'center',
                    formatter: function (cellvalue, options, rowObject) {
                        if (cellvalue == 1) {
                            return '<span class=\"label label-success\">进账</span>';
                        } else if (cellvalue == 0) {
                            return '<span class=\"label label-primary\">出账</span>';
                        }
                    } },
                { label: '金额', name: 'ChangeAmount', width: 80, align: 'right' },
                { label: '下单人ID', name: 'TAccount', width: 80, align: 'left' },
                { label: '下单人姓名', name: 'TAccountName', width: 160, align: 'left' },
                {
                    label: '下单时间', name: 'TriggerTime', width: 80, align: 'left',
                    formatter: "date", formatoptions: { srcformat: 'Y-m-d H:i:s', newformat: 'Y-m-d H:i:s' }
                }
            ],
            pager: "#gridPager",
            sortname: 'TriggerTime desc',
            viewrecords: true,
            //toolbar : [ true, "bottom" ],
            footerrow:true,
            gridComplete: completeMethod
        });
        $("#btn_search").click(function () {
            $gridList.jqGrid('setGridParam', {
                postData: { keyword: $("#txt_keyword").val(),ChangeType:$("#txt_ChangeType").val(),IsIncome:$("#txt_IsIncome").val(),beginTime: $("#BeginTime").val(),endTime: $("#EndTime").val() },
            }).trigger('reloadGrid');
        });
    }

    function completeMethod()
    {
        var a=$("#txt_keyword").val();
        $.ajax({
            url: "/SystemManage/User/GetAllCompanyAccount?keyword="+$("#txt_keyword").val()+"&ChangeType="+$("#txt_ChangeType").val()+"&IsIncome="+$("#txt_IsIncome").val()+"&beginTime="+$("#BeginTime").val()+"&endTime="+$("#EndTime").val()+"",
            //postData: { keyword: $("#txt_keyword").val(),beginTime: $("#BeginTime").val(),endTime: $("#EndTime").val() },
            success: function(result){
                $("#gridList").footerData('set', { Account: '合计:'+result.SumAmount, ChangeType: '公司进账：'+result.InSum, TAccountName:'公司出账：'+result.OutSum});
            }
        });
   }

    function btn_add() {
        $.modalOpen({
            id: "Form",
            title: "新增用户",
            url: "/SystemManage/User/Form",
            width: "700px",
            height: "550px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }
    function btn_edit() {
        var keyValue = $("#gridList").jqGridRowValue().F_Id;
        $.modalOpen({
            id: "Form",
            title: "修改用户",
            url: "/SystemManage/User/Form?keyValue=" + keyValue,
            width: "700px",
            height: "550px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }
    function btn_delete() {
        $.deleteForm({
            url: "/SystemManage/User/DeleteForm",
            param: { keyValue: $("#gridList").jqGridRowValue().F_Id },
            success: function () {
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        })
    }
    function btn_details() {
        var keyValue = $("#gridList").jqGridRowValue().F_Id;
        $.modalOpen({
            id: "Details",
            title: "查看用户",
            url: "/SystemManage/User/Details?keyValue=" + keyValue,
            width: "700px",
            height: "550px",
            btn: null,
        });
    }
    function btn_revisepassword() {
        var keyValue = $("#gridList").jqGridRowValue().F_Id;
        var Account = $("#gridList").jqGridRowValue().F_Account;
        var RealName = $("#gridList").jqGridRowValue().F_RealName;
        $.modalOpen({
            id: "RevisePassword",
            title: '重置密码',
            url: '/SystemManage/User/RevisePassword?keyValue=' + keyValue + "&account=" + escape(Account) + '&realName=' + escape(RealName),
            width: "450px",
            height: "260px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }
    function btn_disabled() {
        var keyValue = $("#gridList").jqGridRowValue().F_Id;
        $.modalConfirm("注：您确定要【禁用】该项账户吗？", function (r) {
            if (r) {
                $.submitForm({
                    url: "/SystemManage/User/DisabledAccount",
                    param: { keyValue: keyValue },
                    success: function () {
                        $.currentWindow().$("#gridList").trigger("reloadGrid");
                    }
                })
            }
        });
    }
    function btn_enabled() {
        var keyValue = $("#gridList").jqGridRowValue().F_Id;
        $.modalConfirm("注：您确定要【启用】该项账户吗？", function (r) {
            if (r) {
                $.submitForm({
                    url: "/SystemManage/User/EnabledAccount",
                    param: { keyValue: keyValue },
                    success: function () {
                        $.currentWindow().$("#gridList").trigger("reloadGrid");
                    }
                })
            }
        });
    }
</script>

<div class="topPanel">
    <div class="toolbar">
        <div class="btn-group">
        </div>
        <div class="btn-group">
            <a id="NF-add" authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_add()"><i class="fa fa-plus"></i>新建用户</a>
        </div>
        <script>$('.toolbar').authorizeButton()</script>
    </div>
    <div class="search">
        <table>
            <tr>
                <td>
                    <div class="input-group">
                        <input id="txt_keyword" type="text" class="form-control" placeholder="会员ID" style="width: 200px;">
                        <select id="txt_ChangeType" class="form-control" style="width:200px;">
                            <option value="" selected>全部</option>
                            <option value="用户提现">用户提现</option>
                            <option value="用户转账">用户转账</option>
                            <option value="用户充值">用户充值</option>
                            <option value="管理奖收入">管理奖收入</option>
                            <option value="个人所得税">个人所得税</option>
                            <option value="个人孵化基金">个人孵化基金</option>
                            <option value="公司孵化基金">公司孵化基金</option>
                            <option value="公司进入一个点位">公司进入一个点位</option>
                            <option value="晋升消费组经理">晋升消费组经理</option>
                            <option value="消费组经理晋升经营组新组员">消费组经理晋升经营组新组员</option>
                            <option value="经营组经理晋升经营组新组员">经营组经理晋升经营组新组员</option>
                            <option value="晋升经营组经理">晋升经营组经理</option>
                            <option value="经营组进入新组员">经营组进入新组员</option>
                            <option value="经营组进入第八个新组员">经营组进入第八个新组员</option>
                            <option value="第一轮金额">第一轮金额</option>
                            <option value="福利车奖励">福利车奖励</option>
                            <option value="福利房奖励">福利房奖励</option>
                            <option value="复投账户">复投账户</option>
                            <option value="提现手续费">提现手续费</option>
                            <option value="省代理分成">省代理分成</option>
                            <option value="市代理分成">市代理分成</option>
                            <option value="区县代理分成">区县代理分成</option>
                            <option value="省代理赠送15个点位">省代理赠送15个点位</option>
                            <option value="市代理赠送7个点位">市代理赠送7个点位</option>
                            <option value="区县代理赠送7个点位">区县代理赠送7个点位</option>
                            <option value="省代理推荐奖励">省代理推荐奖励</option>
                            <option value="市代理推荐奖励">市代理推荐奖励</option>
                            <option value="区县代理推荐奖励">区县代理推荐奖励</option>                            
                        </select>
                        <select id="txt_IsIncome" class="form-control" style="width:200px;">
                            <option value="" selected>全部</option>
                            <option value="1">进账</option>
                            <option value="0">出账</option>
                        </select>
                        <input id="BeginTime" type="text" class="form-control input-wdatepicker" placeholder="起止日期" onfocus="WdatePicker()" style="width: 200px;" />
                        <input id="EndTime" type="text" class="form-control input-wdatepicker" placeholder="截至日期" onfocus="WdatePicker()" style="width: 200px;" />
                        <span class="input-group-btn">
                            <button id="btn_search" type="button" class="btn  btn-primary"><i class="fa fa-search"></i></button>
                        </span>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</div>
<div class="gridPanel">
    <table id="gridList"></table>
    <div id="gridPager"></div>
</div>
